Given /^the following (.+) record$/ do |factory,table|
  # table is a Cucumber::Ast::Table
  table.hashes.each do |hash|
    factory.classify.constantize.create!(hash)
  end
end

Given /^the following (.+) record for testing$/ do |factory,table|
  # table is a Cucumber::Ast::Table
  table.hashes.each do |hash|
    data = factory.classify.constantize.new
    category = Category.find_by_id(hash[3])
    data.category=(category)
    data.message = hash[0]
    data.agree = hash[0]
    data.disagree = hash[0]
    data.save
  end
end


Given /^I login as "([^\"]*)" with password "([^\"]*)"$/ do |username, password|
  visit "/"
  fill_in "login" , :with =>username
  fill_in "password", :with =>password
  click_button "Log in"
end
